#include<stdio.h>
#include<unistd.h>
int global_value=100;

int main()
{
    pid_t pid=fork();

    if(pid==0)
    {
        int cnt=0;
        while(1)
        {
            cnt++;
            printf("子进程：%d->%p: pid:%d ppid:%d\n",global_value,&global_value,getpid(),getppid());
            sleep(1);

            if(cnt==10)
            {
                global_value=200;
                printf("global_value:100->200\n");
            }
        }
    }
    else 
    {
        while(1)
        {
            sleep(1);
            printf("父进程：%d->%p: pid:%d ppid:%d\n",global_value,&global_value,getpid(),getppid());
        }
    }

    return 0;
}
